package com.fpt.edu.vn.h2tv.dao;

import java.util.List;

import com.fpt.edu.vn.h2tv.dao.entity.TbAccount;
import com.fpt.edu.vn.h2tv.dao.entity.TbBook;

/**
 * Interface for TbBookDAO.
 * 
 * @author MyEclipse Persistence Tools
 */

public interface ITbBookDAO {
	/**
	 * Perform an initial save of a previously unsaved TbBook entity. All
	 * subsequent persist actions of this entity should use the #update()
	 * method. This operation must be performed within the a database
	 * transaction context for the entity's data to be permanently saved to the
	 * persistence store, i.e., database. This method uses the
	 * {@link javax.persistence.EntityManager#persist(Object)
	 * EntityManager#persist} operation.
	 * 
	 * <pre>
	 * EntityManagerHelper.beginTransaction();
	 * ITbBookDAO.save(entity);
	 * EntityManagerHelper.commit();
	 * </pre>
	 * 
	 * @param entity
	 *            TbBook entity to persist
	 * @throws RuntimeException
	 *             when the operation fails
	 */
	public void save(TbBook entity);

	/**
	 * Delete a persistent TbBook entity. This operation must be performed
	 * within the a database transaction context for the entity's data to be
	 * permanently deleted from the persistence store, i.e., database. This
	 * method uses the {@link javax.persistence.EntityManager#remove(Object)
	 * EntityManager#delete} operation.
	 * 
	 * <pre>
	 * EntityManagerHelper.beginTransaction();
	 * ITbBookDAO.delete(entity);
	 * EntityManagerHelper.commit();
	 * entity = null;
	 * </pre>
	 * 
	 * @param entity
	 *            TbBook entity to delete
	 * @throws RuntimeException
	 *             when the operation fails
	 */
	public void delete(TbBook entity);

	/**
	 * Persist a previously saved TbBook entity and return it or a copy of it to
	 * the sender. A copy of the TbBook entity parameter is returned when the
	 * JPA persistence mechanism has not previously been tracking the updated
	 * entity. This operation must be performed within the a database
	 * transaction context for the entity's data to be permanently saved to the
	 * persistence store, i.e., database. This method uses the
	 * {@link javax.persistence.EntityManager#merge(Object) EntityManager#merge}
	 * operation.
	 * 
	 * <pre>
	 * EntityManagerHelper.beginTransaction();
	 * entity = ITbBookDAO.update(entity);
	 * EntityManagerHelper.commit();
	 * </pre>
	 * 
	 * @param entity
	 *            TbBook entity to update
	 * @return TbBook the persisted TbBook entity instance, may not be the same
	 * @throws RuntimeException
	 *             if the operation fails
	 */
	public TbBook update(TbBook entity);

	public TbBook findById(Integer id);

	/**
	 * Find all TbBook entities with a specific property value.
	 * 
	 * @param propertyName
	 *            the name of the TbBook property to query
	 * @param value
	 *            the property value to match
	 * @param rowStartIdxAndCount
	 *            Optional int varargs. rowStartIdxAndCount[0] specifies the the
	 *            row index in the query result-set to begin collecting the
	 *            results. rowStartIdxAndCount[1] specifies the the maximum
	 *            count of results to return.
	 * @return List<TbBook> found by query
	 */
	public List<TbBook> findByProperty(String propertyName, Object value,
			int... rowStartIdxAndCount);

	public List<TbBook> findByBookname(Object bookname,
			int... rowStartIdxAndCount);

	public List<TbBook> findByAuthor(Object author, int... rowStartIdxAndCount);

	public List<TbBook> findByDescription(Object description,
			int... rowStartIdxAndCount);

	public List<TbBook> findByPrice(Object price, int... rowStartIdxAndCount);

	public List<TbBook> findByDiscount(Object discount,
			int... rowStartIdxAndCount);

	public List<TbBook> findByStatus(Object status, int... rowStartIdxAndCount);

	public List<TbBook> findByCategoryid(Object categoryid,
			int... rowStartIdxAndCount);

	public List<TbBook> findByQuantity(Object quantity,
			int... rowStartIdxAndCount);

	public List<TbBook> findByCount(Object count, int... rowStartIdxAndCount);

	/**
	 * Find all TbBook entities.
	 * 
	 * @param rowStartIdxAndCount
	 *            Optional int varargs. rowStartIdxAndCount[0] specifies the the
	 *            row index in the query result-set to begin collecting the
	 *            results. rowStartIdxAndCount[1] specifies the the maximum
	 *            count of results to return.
	 * @return List<TbBook> all TbBook entities
	 */
	
	public List<TbBook> findAll(final int... rowStartIdxAndCount);
	public List<TbBook> findAllBook(int start, int limit, int categoryId, String keyWord);
	public List<TbBook> findBookByKeyword(String keyword);
	public List<TbBook> sortBookByCount();
	public List<TbBook> searchOutOfBook();
	public List<TbBook> findHotBook();
	public Long count(int categoryId, String keyWork);
}